package cn.com.lms.business.examRewrite.persistence.repository;

import cn.com.lms.business.examRewrite.persistence.entity.QuestionCategoryReWriteVo;
import com.bnzj.core.persistence.repository.BaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface QuestionCategoryReWriteVoDao extends BaseRepository<QuestionCategoryReWriteVo,Long> {
    @Query(nativeQuery = true,value = "SELECT object.*,(SELECT count(0) FROM  bnz_exam_question_subject ees WHERE ees.question_id = object.id AND is_delete = 0) subject_count " +
            "FROM (SELECT eq.*,eqc.category_name FROM bnz_exam_question eq JOIN bnz_exam_question_category eqc WHERE eq.category_id = eqc.id and eq.id  " +
            "(SELECT eeq.question_id FROM bnz_exam_exercise_question eeq WHERE eeq.exercise_id =?1)) object")
    List<QuestionCategoryReWriteVo> getQuestionNameAddTypeAddCountById(Long id);
}
